package mysql

import "gorm.io/gorm"

// 用户

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);not null;comment:用户名"`
	Password string `gorm:"type:varchar(32);not null;comment:密码"`
}

// 登录

func (u *User) FirstOrCreate(db *gorm.DB, username string) error {
	return db.Debug().Where("username=?", username).FirstOrCreate(u).Error
}

func (u *User) UserCreate(db *gorm.DB) error {
	return db.Debug().Create(u).Error
}
